package com.demo.springboot.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class LogAspect {

    @Before("execution(* com.demo.springboot.dao..*.*(..))")
    public void logBefore(){
        System.out.println("before method log done..."+AopContext.currentProxy().getClass());
    }

    @After("execution(* com.demo.springboot.dao..*.*(..))")
    public void logAfter(JoinPoint point){
        System.out.println("after method log done...:"+point.getTarget().getClass()+", args="+Arrays.asList(point.getArgs())+", method="+point.getSignature().getName());
    }

}
